package com.scj.beilu.app.helper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.scj.beilu.app.dao.DaoMaster;
import com.scj.beilu.app.dao.GoodsShoppingCarInfoBeanDao;
import com.scj.beilu.app.dao.SearchHistoryEntityDao;
import com.scj.beilu.app.dao.UserInfoEntityDao;

import org.greenrobot.greendao.database.Database;

/**
 */
public class MySQLiteOpenHelper extends DaoMaster.OpenHelper {

    public MySQLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) {
        super(context, name, factory);
    }

    @Override
    public void onUpgrade(Database db, int oldVersion, int newVersion) {

        MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() {
                    @Override
                    public void onCreateAllTables(Database db, boolean ifNotExists) {
                        DaoMaster.createAllTables(db, ifNotExists);
                    }

                    @Override
                    public void onDropAllTables(Database db, boolean ifExists) {
                        DaoMaster.dropAllTables(db, ifExists);
                    }
                }, UserInfoEntityDao.class,
                SearchHistoryEntityDao.class,
                GoodsShoppingCarInfoBeanDao.class);
    }
}
